
###############################
# Alpha Reliability of Outcomes
###############################

# Political activism ----
alphaActivism<-meta_std%>%
  dplyr::select(., activism_1, activism_2, activism_3, activism_4,activism_5)%>%
  as.data.frame()
df_alphaActivism<-cronbach.alpha(alphaActivism, na.rm=TRUE)
df_alphaActivism<-data.frame(Variables=df_alphaActivism$name,
                             Alpha=df_alphaActivism$alpha, 
                             Items=df_alphaActivism$p)

alphaActivism<- meta_std[, c("activism_1", "activism_2", "activism_3", "activism_4","activism_5")]  # Include all items in your scale
alpha(alphaActivism)

# Political Efficacy ----
alphaEfficacy<-meta_std%>%
  dplyr::select(., efficacy_1, efficacy_2, efficacy_3, efficacy_4, efficacy_5, efficacy_6)%>%
  as.data.frame()
df_alphaEfficacy<-cronbach.alpha(alphaEfficacy, na.rm=TRUE)
df_alphaEfficacy<-data.frame(Variables=df_alphaEfficacy$name,
                             Alpha=df_alphaEfficacy$alpha, 
                             Items=df_alphaEfficacy$p)

alphaEfficacy<- meta_std[, c("efficacy_1", "efficacy_2", "efficacy_3", "efficacy_4","efficacy_5", "efficacy_6")]  # Include all items in your scale
alpha(alphaEfficacy) #check

# Confidence in Knowledge ----
alphaConf<-meta_std%>%
  dplyr::select(., pol_confidence_1, pol_confidence_2, pol_confidence_3)%>%
  as.data.frame()
df_alphaConf<-cronbach.alpha(alphaConf, na.rm=TRUE)
df_alphaConf<-data.frame(Variables=df_alphaConf$name,
                             Alpha=df_alphaConf$alpha, 
                             Items=df_alphaConf$p)

alphaConf<- meta_std[, c("pol_confidence_1", "pol_confidence_2", "pol_confidence_3")]  # Include all items in your scale
alpha(alphaConf)

# Political Knowledge ----
alphaKnow<-meta_std%>%
  dplyr::select(., knowledge_2, knowledge_3, knowledge_4, knowledge_5)%>%
  as.data.frame()
df_alphaKnow<-cronbach.alpha(alphaKnow, na.rm=TRUE)
df_alphaKnow<-data.frame(Variables=df_alphaKnow$name,
                         Alpha=df_alphaKnow$alpha, 
                         Items=df_alphaKnow$p)

alphaKnow<- meta_std[, c("knowledge_2", "knowledge_3", "knowledge_4", "knowledge_5")]  # Include all items in your scale
alpha(alphaKnow)

# News openness ----
alphaOpen<-meta_std%>%
  dplyr::select(., news_openness_1, news_openness_2, news_openness_3)%>%
  as.data.frame()
df_alphaOpen<-cronbach.alpha(alphaOpen, na.rm=TRUE)
df_alphaOpen<-data.frame(Variables=df_alphaOpen$name,
                         Alpha=df_alphaOpen$alpha, 
                         Items=df_alphaOpen$p)

alphaOpen<- meta_std[, c("news_openness_1", "news_openness_2", "news_openness_3")]  # Include all items in your scale
alpha(alphaOpen)


# Add an identifier to each data frame to distinguish them
df_alphaActivism$Variables <- "Activism"
df_alphaEfficacy$Variables <- "Efficacy"
df_alphaConf$Variables <- "Confidence in Knowledge"
df_alphaKnow$Variables <- "Knowledge"
df_alphaOpen$Variables <- "News Openness"

# Combine the data frames into one
combined_df <- rbind(df_alphaActivism, df_alphaEfficacy, df_alphaConf, df_alphaKnow, df_alphaOpen)

# Generate a table for the combined data frame
stargazer(combined_df,
          type = "latex",
          summary = FALSE, digits = 2, rownames = FALSE)
